﻿using System;
using System.Collections.Generic;
using System.Text;
// Based off CDC's Epi Info 7 TableColumn class; see http://epiinfo.codeplex.com

namespace NutriStat.Data
{
    public class TableColumn : NutriStat.Data.ITableColumn
    {
        #region Private Members

        private string name;
        private GenericDbColumnType dataType;
        private int? length;
        private int? precision;
        private int? scale;
        private bool isIdentity;
        private bool allowNull;
        private bool isPrimaryKey;
        private string foreignKeyTableName;
        private string foreignKeyColumnName;
        private bool cascadeDelete = false;

        #endregion

        #region Constructors
        
        public TableColumn(string name, GenericDbColumnType dataType, bool allowNull)
        {
            this.name = name;
            this.dataType = dataType;
            this.allowNull = allowNull;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, bool allowNull, bool isPrimaryKey)
        {
            this.name = name;
            this.dataType = dataType;
            this.allowNull = allowNull;
            this.isPrimaryKey = isPrimaryKey;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, bool allowNull, bool isPrimaryKey, bool isIdentity)
        {
            this.name = name;
            this.dataType = dataType;
            this.allowNull = allowNull;
            this.isPrimaryKey = isPrimaryKey;
            this.isIdentity = isIdentity;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, bool allowNull, string foreignKeyTableName, string foreignKeyColumnName, bool cascadeDelete)
        {
            this.name = name;
            this.dataType = dataType;
            this.allowNull = allowNull;
            this.foreignKeyTableName = foreignKeyTableName;
            this.foreignKeyColumnName = foreignKeyColumnName;
            this.cascadeDelete = cascadeDelete;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, bool allowNull, string foreignKeyTableName, string foreignKeyColumnName)
        {
            this.name = name;
            this.dataType = dataType;
            this.allowNull = allowNull;
            this.foreignKeyTableName = foreignKeyTableName;
            this.foreignKeyColumnName = foreignKeyColumnName;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int length, bool allowNull)
        {
            this.name = name;
            this.dataType = dataType;
            this.length = length;
            this.allowNull = allowNull;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int length, bool allowNull, bool isPrimaryKey)
        {
            this.name = name;
            this.dataType = dataType;
            this.length = length;
            this.allowNull = allowNull;
            this.isPrimaryKey = isPrimaryKey;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int length, bool allowNull, string foreignKeyTableName, string foreignKeyColumnName)
        {
            this.name = name;
            this.dataType = dataType;
            this.length = length;
            this.allowNull = allowNull;
            this.foreignKeyTableName = foreignKeyTableName;
            this.foreignKeyColumnName = foreignKeyColumnName;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int precision, int scale, bool allowNull)
        {
            this.name = name;
            this.dataType = dataType;
            this.precision = precision;
            this.scale = scale;
            this.allowNull = allowNull;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int precision, int scale, bool allowNull, bool isPrimaryKey)
        {
            this.name = name;
            this.dataType = dataType;
            this.precision = precision;
            this.scale = scale;
            this.allowNull = allowNull;
            this.isPrimaryKey = isPrimaryKey;
        }
        
        public TableColumn(string name, GenericDbColumnType dataType, int precision, int scale, bool allowNull, string foreignKeyTableName, string foreignKeyColumnName)
        {
            this.name = name;
            this.dataType = dataType;
            this.precision = precision;
            this.scale = scale;
            this.allowNull = allowNull;
            this.foreignKeyTableName = foreignKeyTableName;
            this.foreignKeyColumnName = foreignKeyColumnName;
        }

        #endregion

        #region Public Properties
        
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
        
        public GenericDbColumnType DataType
        {
            get
            {
                return dataType;
            }
            set
            {
                dataType = value;
            }
        }
        
        public int? Length
        {
            get
            {
                return length;
            }
            set
            {
                length = value;
            }
        }
        
        public int? Precision
        {
            get
            {
                return precision;
            }
            set
            {
                precision = value;
            }
        }
        
        public int? Scale
        {
            get
            {
                return scale;
            }
            set
            {
                scale = value;
            }
        }
        
        public bool AllowNull
        {
            get
            {
                return allowNull;
            }
            set
            {
                allowNull = value;
            }
        }
        
        public bool IsPrimaryKey
        {
            get
            {
                return isPrimaryKey;
            }
            set
            {
                isPrimaryKey = value;
            }
        }
        
        public string ForeignKeyTableName
        {
            get
            {
                return foreignKeyTableName;
            }
            set
            {
                foreignKeyTableName = value;
            }
        }
        
        public string ForeignKeyColumnName
        {
            get
            {
                return foreignKeyColumnName;
            }
            set
            {
                foreignKeyColumnName = value;
            }
        }
        
        public bool CascadeDelete
        {
            get { return cascadeDelete; }
            set { cascadeDelete = value; }
        }
        
        public bool IsIdentity
        {
            get
            {
                return isIdentity;
            }
            set
            {
                isIdentity = value;
            }
        }

        #endregion
    }
}
